
const datas = {
    operators: [],
    checkOrder:{
        warningEventId: '',
        responseOfficerId: '',
        eventProgress: '1',
        handleOpinion: '大屏派单'

    },
    warningEventId: '',
    warningEventIds: store.get('warningEventIds') || [],
    meetingId: '',
    meetingIds: store.get('meetingIds') || [],
    scroll: new IScroll('.alertItem', {
        mouseWheel: true,
        // scrollbars: true
    }),
    token: 'd7e7627d-22f3-4f70-b14d-253bb3bf6e1e',
    base_url: 'http://117.159.206.248:20888',

    arg: {
        type: 'post',
        dataType: 'json'
    },
    dateFormatter: function (s) {
        return s < 10 ? '0' + s : s
    },
    getQueryTime: function () {
        const t = new Date()
        return [
            t.getFullYear(),
            this.dateFormatter(t.getMonth() + 1),
            this.dateFormatter(t.getDate())
        ].join('-')
    },
    getQueryTimes: function () {
        const t = new Date()
        return [
            t.getFullYear(),
            this.dateFormatter(t.getMonth() + 1),
            this.dateFormatter(t.getDate() - 1)
        ].join('-')
    },
    bedapplyAnalysis: function () {
        var o = $.Deferred()
        this.arg.url = this.base_url + '/ccp/front/sh/bedapplyAnalysis!execute'
        this.arg.data = {
            placeId: 9,
            uid: 'bedapplyAnalysis010',
            applyTime: this.getQueryTimes(),
            token: this.token
        }
        $.ajax(this.arg).done(function (res) {
            o.resolve(res)
        })
        return o.promise()
    },
    meetingList: function () {
        var o = $.Deferred()
        this.arg.url = this.base_url + '/ccp/front/sh/meeting!execute?uid=M006'
        this.arg.data = {
            passFlag: 1,
            delFlag: 1,
            currentPage: 1,
            pageSize: 20,
            token: this.token
        }
        $.ajax(this.arg).done(function (res) {
            o.resolve(res)
        })
        return o.promise()
    },
    alertList: function() {
        var o = $.Deferred()
        this.arg.url = this.base_url + '/ccp/front/sh/warningEvent!execute'
        this.arg.data = {
            currentPage: 1,
            pageSize: 20,
            uid: 'c001_2',
            token: this.token
        }
        $.ajax(this.arg).done(function (res) {
            o.resolve(res)
        })
        return o.promise()
    },

    busHomeList: function () {
        var o = $.Deferred()
        this.arg.url = this.base_url + '/ccp/business/listBusinessRoomApplyInfo'
        this.arg.data = {
            page: 1,
            pageSize: 10,
            token: this.token
        }
        $.ajax(this.arg).done(function (res) {
            o.resolve(res)
        })
        return o.promise()
    },
    getAllOperationGroup: function () {
        var o = $.Deferred()
        this.arg.url = this.base_url + '/ccp/operation/getAllOperationGroup'
        this.arg.data = {
            pIds: '9',
            token: this.token
        }
        $.ajax(this.arg).done(function (res) {
            o.resolve(res)
        })
        return o.promise()
    },

    findDayConsumeAndRecharge: function () {
        var o = $.Deferred()
        this.arg.url = this.base_url + '/ccp/MonitoringCenterController/transferResumeMethod'
        this.arg.data = {
            method: '/consume/chart/findDayConsumeAndRecharge',
            json: JSON.stringify({
                time: this.getQueryTime(),
            }),
            token: this.token
        }
        $.ajax(this.arg).done(function (res) {
            o.resolve(res)
        })
        return o.promise()
    },

    handleAlert: function () {
        var o = $.Deferred()
        const warningEventId = datas.checkOrder.warningEventId
        const handleId = datas.checkOrder.responseOfficerId
        const eventProgress = 1
        const handleOpinion = '大屏派单'
        this.arg.url = this.base_url + '/ccp/front/sh/warningEvent!execute?uid=c029'
        this.arg.data = {
            warningEventId,
            handleId,
            eventProgress,
            handleOpinion,
            token: this.token
        }
        
        $.ajax(this.arg).done(function (res) {
            console.log(res)
            o.resolve(res)
        }).fail(function (err) {
            console.log(err)
        })
        return o.promise() 
    },
    handleAlert2: function() {
        var o = $.Deferred()
        this.warningEventIds.push(datas.checkOrder.warningEventId)
        store.set('warningEventIds', this.warningEventIds)
        console.log(store.get('warningEventIds'))
        o.resolve()
        return o.promise()

    },
    getCountData: function (gretting) {
        var o = $.Deferred()
        datas.arg.url = datas.base_url + '/ccp/seat/getCountData'
        console.log(gretting)
        datas.arg.data = {
            placeId: 9,
            token: datas.token
        }
        
        $.ajax(datas.arg).done(function (res) {
            gretting.count = res
            o.resolve(gretting)
        }).fail(function(res) {
        })

        return o.promise()
    },

}
